#ifndef MONSTER_H
#define MONSTER_H



#include "Globals.h"
#include "LifeForm.h"
#include "Soil.h"
#include "Man.h"

/*! \class Monster
 *  \brief Attributes of the monsters in the game
 *
 *  This class inherits from LifeForm. The monster object should have the ability
 *  to move towards dig dug, move randomly, have a disembodied form and locate tunnels.
 *
 *  \author Jackline Atsango
 *  \author Jean pierre vieira Pereira
 *  \version 3
 *  \date 27 September 2012
 */

enum MONSTER_STATE
{
    ALIVE_NORMAL = 1,
    ALIVE_DISEMBODIED,
    DEAD
};

enum STARTING_POS
{
    TOP_LEFT=1,
    TOP_RIGHT,
    BOTTOM_LEFT,
    BOTTOM_RIGHT
};

class Monster: public LifeForm
{
    public:

/*! \fn Monster
 *  \brief create monster object
 *  \param dig_dug an object from Man
 *  \param soil an object from Soil
 */
        Monster(shared_ptr<Man > dig_dug, shared_ptr<Soil > soil);

/*! \fn void initialise
 *  \brief sets a monster randomly in an existing tunnel
 *
 *  Uses LifeForm::initialise to place the monster
 */
        void initialise();

/*! \fn void update
 *  \brief updates the object position based on the object state
 *
 *  If the monster object is in a 50x50 square, it can query if there is a tunnel ahead,
 *  if the monster is within a tunnel, LifeForm::update is used and if the monster is in
 *  disembodied form, the position is updated accordingly.
 */
        void update();

/*! \fn bool get_disembody
 *  \returns boolean representing disembodied or normal monster
 */
        bool get_disembody();

/*! \fn int get_monster_state
 *  \returns integer enumeration of the monster's state, normal, disembodied or dead.
 */
        int get_monster_state();

    private:

        void check_soil();
        void move_monster_norm();
        void move_monster_disembodied();
        void update_random_bool();
        void update_random_number();
        void update_random_number3();

        void update_top_left();
        void update_top_right();
        void update_bottom_left();
        void update_bottom_right();

        void update_face_direction();

        bool _hole_up;
        bool _hole_down;
        bool _hole_left;
        bool _hole_right;

        int _monster_state;
        int _face_direction;

        bool _toward_target;
        bool _disembody;

        bool _random_bool;
        int _random_number;
        int _random_number2;
        int _random_number3;

        shared_ptr<Man > _DigDug;
        shared_ptr<Soil > _soil;

        int _top_left;
        int _top_right;
        int _bottom_left;
        int _bottom_right;

        int _x_diff;
        int _y_diff;
        int _old_pos_x;
        int _old_pos_y;
};

#endif // MONSTER_H
